$(function(){
	$("#edit1").click(function(){
		$("#subtest").hide();
		$("#subInfo").show();
		
	})
	
	$("#save1").click(function(){
		var email = $("#email").val();
		var pass1 = $("#password").val();
		var pass2 = $("#rtpassword").val();
		var name = $("#fullname").val();
		var birthday = $("#datetimepicker").val().substr(0, 10);
		var gender = $("#gender").val();
		if(pass1==pass2){
			$.blockUI();
			
		$.ajax({
			url:"basicinfo",         
			type: "GET",
	        data:{
	        	email:email,
	        	pass:pass1,
	        	name:name,
	        	birthday:birthday,
	        	gender:gender
	        },
	        contentType: "application/json; charset=utf-8",
	        dataType: 'json',
	        error: function() {
	        	$.unblockUI();
	        	$("#subtest").show();
	    		$("#subInfo").hide();
	    		apprise("Update User didn't success");
	        },
	        success: function(data) {
	        	$("#email1").html(data.email);
	        	$("#fullname1").html(data.fullName);
	        	if(data.birthday){
	        	var yyyy=data.birthday;
	        	var dd=data.birthday;
	        	var mm=data.birthday;
	        	yyyy=yyyy.toString().substring(0,4);
	        	mm=mm.toString().substring(5,7);
	        	dd=parseInt(dd.toString().substring(8,10));
	        	var a=data.birthday.toString().substring(0,10);
	        	$("#birthday1").html(mm+"/"+dd+"/"+yyyy);
	        	 $("#datetimepicker").val(mm+"/"+dd+"/"+yyyy);
	        	}
//	        	var mm=data.birthday.toString().substring(0,4);
//	        	var dd=data.birthday.toString().substring(0,4);
	        	//2013-01-23
	        	
	        	$("#gender1").html(data.gender);
	        	//$("#fullname1").val(data.fullName);
	    		$("#password").val(data.password);
	    		$("#fullname").val(data.fullName);
	    		
	    		$("#gender").val(data.gender);
	    		$.unblockUI();
	        	$("#subtest").show();
	    		$("#subInfo").hide();
	    		apprise('update user success!!');
	        }
	        	
		})
		}
		else{
			apprise("retype password is not match!!!!!!!!")
		}
	})
	$("#save2").click(function(){
		var email = $("#email").val();
		var company = $("#company").val();
		var website = $("#website").val();
		$.blockUI();
		$.ajax({
			url:"companyinfo",         
			type: "GET",
	        data:{
	        	email:email,
	        	company:company,
	        	website:website
	        },
	        contentType: "application/json; charset=utf-8",
	        dataType: 'json',
	        error: function() {
	        	$.unblockUI();
	        	apprise("Update User didn't success");
	        },
	        success: function(data) {
	        	$("#company1").html(data.company);
	        	$("#website1").html(data.website);
	        	//$("#fullname1").val(data.fullName);
	    		$("#company").val(data.company);
	    		$("#website").val(data.website);
	        	$("#subContacttest").show();
	    		$("#subcontact").hide();
	    		$.unblockUI();
	    		apprise("Update User success");
	        }
	        	
		})
	})
//	$("#bt-upload").click(function(){
//		var email = $("#email").val();
//		$.ajax({
//			url:"uploadavatar",         
//			type: "GET",
//	        data:{
//	        	email:email
//	        },
//	        contentType: "application/json; charset=utf-8",
//	        dataType: 'html',
//	        error: function() {
//	        	apprise("aaa")
//	        },
//	        success: function(data) {
//	        	apprise("bbbbbbbbbb");
//	        }
//	        	
//		})
//	})
	
	
	
	
	$("#edit2").click(function(){
		$("#subContacttest").hide();
		$("#subcontact").show();
	})
	
	$("#datetimepicker").datepicker({});
	
	
})
